package org.fuxia.im.core.entries;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 网络传输实体信息，在本系统中，网络传输的所有数据均使用JSON格式，
 * 关于对象序列化成JSON，采用了Alibaba的FastJSon框架
 *
 */
public class ECPacket implements Serializable
{

	@JSONField(serialize = false)
	private static final long	serialVersionUID	= 1L;

	private String				className			= ECPacket.class.getName();

	// 消息从那个客户端发送过来
	private String				from;
	// 消息发送到那个客户端,如果是多个客户端，那么用空格分开
	private String				to;
	//消息类型
	private String				messageType;
	//请求传递的参数
	private Map<String, String>	params;

	public String getFrom()
	{
		return from;
	}

	public void setFrom(String from)
	{
		this.from = from;
	}

	public String getTo()
	{
		return to;
	}

	public void setTo(String to)
	{
		this.to = to;
	}

	public String getMessageType()
	{
		return messageType;
	}

	public void setMessageType(String messageType)
	{
		this.messageType = messageType;
	}

	public Map<String, String> getParams()
	{
		return params;
	}

	public void setParams(Map<String, String> params)
	{
		this.params = params;
	}

	public String getClassName()
	{
		return className;
	}

	public void setClassName(String className)
	{
		this.className = className;
	}

	public void addParam(String pName , String value)
	{
		if (this.params == null)
		{
			this.params = new HashMap<String, String>();
		}
		this.params.put(pName, value);
	}

	public String getParameter(String param)
	{
		return this.params.get(param);
	}

	@Override
	public String toString()
	{
		return "ECPacket [from=" + from + ", to=" + to + ", messageType=" + messageType + ", params=" + params + "]";
	}

}
